<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>90_数组遍历</title>
		<script>
			//任何类型的值都可以成为数组中的元素
			let arr = [1, "hello",
				true, null, {
					name: "孙悟空"
				}, () => {}
			]
			//创建数组时尽量要确保数组中存储的数据的类型是相同。

			arr = [
				"唐三藏",
				"孙悟空",
				"沙僧",
				"猪八戒"
			]

			for (let i = 0; i < arr.length; i++) {
				console.log(arr[i]);
			}
			/* 
				定义一个Person类，类中有两个属性name和age
				然后创建几个Person对象，将其添加到一个数组中 I
				遍历数组，并打印未成年人的信息
			 */
			class Person {
				constructor(name, age) {
					this.name = name;
					this.age = age;
				}
			}

			var personArr = [new Person("孙悟空",
				10), new Person("长臂猿", 19), new Person("大猩猩", 4)];

			let info = "";
			for (let i = personArr.length - 1; i >= 0; i--) {
				let p = personArr[i];
				if (p.age < 18) {
					info = info + p.name + ":" + p.age + ",";
				}
			}
			console.log("动物信息", info);
		</script>
	</head>
	<body>
	</body>
</html>